/********************
 * Block,h
 * This file describe how a single block formed in a whole cube
 * We use a coordinate to describe the location of each cube.
 */

//colors: Yellow Red Blue Orange Green White  
#ifndef BLOCK_H
#define BLOCK_H
#define hBlk 10.0f
#include <GL/glut.h>
#include <vector>
#include "quad.h"

    //static GLfloat hBlk = 10.0f;     //size of half block

    //define colors
    static GLfloat YELLOW[3]  = {1.0f, 1.0f, 0};
    static GLfloat RED[3]     = {1.0f, 0.0f, 0.0f};
    static GLfloat BLUE[3]    = {0, 0, 1.0f};
    static GLfloat ORANGE[3]  = {0.980f, 0.490f, 0.039f};
    static GLfloat GREEN[3]   = {0, 1.0f, 0};
    static GLfloat WHITE[3]   = {0.7f, 0.7f,0.7f};
    //define vertex
    static const float vertex2f[][2] = 
    {
        -3*hBlk,  3*hBlk,
        -hBlk,    3*hBlk,
        hBlk,     3*hBlk,
        3*hBlk,   3*hBlk,

        -3*hBlk,  hBlk,
        -hBlk,  hBlk,
        hBlk,  hBlk,
        3*hBlk,  hBlk,

        -3*hBlk,  -hBlk,
        -hBlk,  -hBlk,
        hBlk,  -hBlk,
        3*hBlk,  -hBlk,
        
        -3*hBlk,  -3*hBlk,
        -hBlk,  -3*hBlk,
        hBlk,  -3*hBlk,
        3*hBlk,  -3*hBlk,

    };

    static const int vertex2fIndex[][4] = 
    {
        5, 1, 0, 4,
        6, 2, 1, 5,
        7, 3, 2, 6,
        9, 5, 4, 8,
        10, 6, 5, 9,
        11, 7, 6, 10,
        13, 9, 8, 12,
        14, 10, 9, 13,
        15, 11, 10, 14
    };



class Block
{
private:
    std::vector<Quad> faces;

    int coorToIndex(int x, int y) const
    {
        
        switch(y)
        {
            case 1:
                switch(x)
                {
                    case -1: return 0;
                    case 0: return 1;
                    case 1: return 2;
                }
            case 0:
                switch(x)
                {
                    case -1: return 3;
                    case 0: return 4;
                    case 1: return 5;
                }
            case -1:
                switch(x)
                {
                    case -1: return 6;
                    case 0: return 7;
                    case 1: return 8;
                }
        }
    }
        
public:
    Block(int*);        //use location to initialize cube
    void glDraw();           //draw particular
    void rotate(char, GLfloat);    //rotate
};


#endif
